package com.far.permissions.dto.resp;

import lombok.Data;

import java.io.Serializable;

@Data
public class BaseRespDTO<T> implements Serializable {
    private String message;
    private String code;
    private T data;

    private BaseRespDTO(String message, String code, T data) {
        this.message = message;
        this.code = code;
        this.data = data;
    }

    private BaseRespDTO() {
    }

    public static <T> BaseRespDTO<T> success(T data) {
        return new BaseRespDTO<T>("success", "200", data);
    }

    public static BaseRespDTO<Void> success() {
        return success(null);
    }

    public static <T> BaseRespDTO<T> fail(String message, String code) {
        return new BaseRespDTO<T>(message, code, null);
    }
}
